﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;
namespace Server_NhaSach.BusinessLayer
{
    public class ChiTietTraHangNCCBlo
    {
        #region "Khai báo các biến"
        private ChiTietTraHangNCCDAO da;
        private ChiTietTraHangNCCDTO _CTDHNCC;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public ChiTietTraHangNCCDTO CTDHNCC
        {
            get { return _CTDHNCC; }
            set { _CTDHNCC = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public ChiTietTraHangNCCBlo()
        {
            _CTDHNCC = new ChiTietTraHangNCCDTO();
            da = new ChiTietTraHangNCCDAO();
        }
        public bool InsertCTTraHangNCC(string maMH, string maTHNCC, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            CTDHNCC = new ChiTietTraHangNCCDTO(maMH, maTHNCC, soLuong, donGia, chietKhau, thanhTien);
            if (!da.InsertCTTHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTTraHangNCC(string maMH, string maTHNCC, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            CTDHNCC = new ChiTietTraHangNCCDTO(maMH, maTHNCC, soLuong, donGia, chietKhau, thanhTien);
            if (!da.UpdateCTTHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTTraHangNCC(string MaMH, string MaTHNCC)
        {
            if (!da.DeleteCTTHNCC(MaMH, MaTHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_ChiTietTraHangNCC()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTTHNCC();
            return ds;
        }
        #endregion
    }
}